<script setup>
	import { onLoad } from '@dcloudio/uni-app'
	import { reactive, getCurrentInstance, ref } from 'vue'
	onLoad((options)=>{
		console.log('在options接收home传递过来的数据:' + options)
		DeviceData.temperature = options.temperature
		DeviceData.humidity = options.humidity
		DeviceData.phValue = options.phValue
	})
	const DeviceData = reactive({
		temperature: null,
		humidity:null,
		phValue: null
	})
	const props = defineProps({
		temperature: Number,
		humidity:Number,
		phValue: Number
		// manualEntryInfo : {
		// 	showStatus: false,
		// 	deviceData:{
		// 		temperature : null,
		// 		humidity : null,
		// 		phValue : null
		// 	}
		// }
	})
	 console.log('在props接收index传递过来的数据QWQ:', props.temperature, props.humidity, props.phValue);
	// import { ref,getCurrentInstance } from 'vue'
	// import { onLoad } from '@dcloudio/uni-app'
	//     // $instance => this
	// const $instance = ref(getCurrentInstance().proxy)
	// onLoad((options) => {
	// 	const eventChannel = $instance.value.getOpenerEventChannel()
	// 	console.log(eventChannel);
	// 	eventChannel.on('manualEntryInfo', (value) => {
	//         console.log('在options接收home页面eventChannel传递过来的数据:', value);
	// 	})
	// })
	
	
	

	// const emit = defineEmits(['getManualEntryData'])
	// const confirmData =()=>{
		
	// 	console.log(manualEntryInfo);
	// 	emit('getManualEntryData', manualEntryInfo)
	// }
	
	//回传参数给index
	const $instance = ref(getCurrentInstance().proxy)
	function goBack(){
		uni.navigateBack({
			delta:1
		})
		const enventChannel = $instance.value.getOpenerEventChannel()
		enventChannel.emit('acceptDataFormDetail', {
			data: '这里是detail传递给home页的数据'
		})
	}
	
	
	const onCancel =() =>{
		console.log('conCancel');
	}
	const onConfirm =() =>{
		// console.log('onConfirm');
		// console.log('在props接收index传递过来的数据:', DeviceData.temperature, DeviceData.humidity, DeviceData.phValue);
		
		
		uni.navigateBack({
			delta:1
		})
		const enventChannel = $instance.value.getOpenerEventChannel()
		enventChannel.emit('acceptDataFormDetail', {
			data: '这里是detail传递给home页的数据'
		})
	}
</script>

<template>
	<!-- <up-modal title='数据采集' showCancelButton @cancel="manualEntryInfo.showStatus = false;" @confirm="confirmData"> -->
	<view class="container">
		<view class="manualEntry">
			<view class="inp">
				<span style="height: 50rpx;">温度：</span>
				<up-input class="inp" placeholder="请输入温度" border="bottom" :modelValue="DeviceData.temperature" clearable></up-input>
			</view>
			<view class="inp">
				<span style="height: 50rpx;">湿度：</span><up-input class="inp" placeholder="请输入湿度" border="bottom" :modelValue="DeviceData.humidity" clearable></up-input>
			</view>
			<view class="inp">
				<span style="height: 50rpx;">酸碱度：</span><up-input class="inp" placeholder="请输入酸碱度" border="bottom" :modelValue="DeviceData.phValue" clearable></up-input>
			</view>
		</view>
		<view class="confirm">
			<up-button style="width: 200rpx;" type="info" :plain="true" text="取消" @click="onCancel"></up-button>
			<up-button style="width: 200rpx;" type="primary" :plain="false" text="确定" @click="onConfirm"></up-button>
		</view>
	</view>
	<!-- </up-modal> -->
</template>

<style lang="scss" scoped>
	// @import "@/uni_modules/uview-plus/index.scss";
	
	.container{
		// border: 1rpx red solid;
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		transform: translateZ(1);
		// display: flex;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.manualEntry{
		width: 80%;
		// border: 1rpx red solid;
		margin-top: 60rpx;
		// flex-direction: column;
		// justify-content: center;
		
	}
	.inp{
		// border: 1rpx red solid;
		margin-top: 30rpx;
		display: flex;
		align-items:flex-end;
	}
	.confirm{
		width: 80%;
		// border: 1rpx red solid;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		margin-top: 40rpx;
	}
</style>